package com.wanmait.happyheating.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wanmait.happyheating.pojo.HeatingNumber;
import com.wanmait.happyheating.pojo.Userinfo;
import com.wanmait.happyheating.service.HeatingNumberService;
import com.wanmait.happyheating.service.UserinfoService;
import com.wanmait.happyheating.util.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController//指定他是一个控制器的controller注解，每个方法默认加上注解@ResponseBody
@RequestMapping("/manage")//公用的路径
public class UserAccountController
{
    @Resource//
    private UserinfoService userinfoService;//链接什么数据库就写什么Service
    @Resource
    private HeatingNumberService heatingNumberService;

    @PostMapping("showUserinfoType")//请求方式
    public Result findUserinfoType(Integer id)//@RequsetBody注解 接收对象
    {
        LambdaQueryWrapper<Userinfo> userinfoTypeLambdaQueryWrapper=new LambdaQueryWrapper<>();//创建一个 Lambda表达式
        userinfoTypeLambdaQueryWrapper.eq(Userinfo::getId,id);//把括号里的数据暂时放到QueryWrapper
       Userinfo userinfo= userinfoService.getById(id);//获取ID用户的信息

        //List<Userinfo> userinfoTypes=userinfoService.list(userinfoTypeLambdaQueryWrapper);//

        return Result.success(userinfo);
    }
    @PostMapping("showIDcard")
    public Result showIDcard(Integer id)
    {
        LambdaQueryWrapper<HeatingNumber> heatingNumberLambdaQueryWrapper=new LambdaQueryWrapper<>();
        heatingNumberLambdaQueryWrapper.eq(HeatingNumber::getId,id);
        HeatingNumber heatingNumber =heatingNumberService.getById(id);

        return  Result.success(heatingNumber);
    }

}
